/**
 * 菜单
 */

const express = require("express")
const { body } = require("express-validator")
const { getRouter, getMenuListTree, insertOrUpdateMenu, deleteMenu, } = require("@root/services/admin/menu.service.js")
const router = express.Router()


router.get('/getRouters', getRouter)

router.get('/list', getMenuListTree)

const add_update = [
  body('menu_name').notEmpty().escape().withMessage('菜单名不能为空'),
  body('menu_type').notEmpty().escape().withMessage('菜单类型不能为空'),
];
router.post('/', add_update, insertOrUpdateMenu)


router.delete('/', [
  body("ids").isArray({ min: 1 }).withMessage("ids必须是数组,且不能为空"),
  body("ids.*").isInt({ min: 1 }).withMessage("数组中的元素必须是正整数"),
], deleteMenu)



module.exports = router
